import type { IAccount, ILoginResult } from './type'

import type { IDataType } from '../types'
import crvRequest from '../index'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/', // 用法: /users/1
  UserMenus = '/role/' // 用法: role/1/menu
}

//1:登录
export function accountlogin(account: IAccount) {
  console.log('登录信息是', account)
  return crvRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

//2:用户信息
export function requestUserInfoById(id: number) {
  return crvRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id
  })
}

//3:用户菜单
export function requestUserMenusByRoleId(id: number) {
  return crvRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}

//4:获取
